﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace AirLinq.Providers.Sql {
	public class SqlJoin : SqlSource {
		private readonly SqlSource _left;
		private readonly JoinType _joinType;
		private readonly SqlSource _right;
		private readonly SqlLogicalExpression _condition;

		public SqlJoin(SqlSource left, SqlSource right, JoinType joinType, SqlLogicalExpression condition) {
			if (left == null) {
				throw new ArgumentNullException("left");
			}
			if (right == null) {
				throw new ArgumentNullException("right");
			}
			if (condition == null && joinType != JoinType.Cross) {
				throw new ArgumentNullException("condition");
			}
			_left = left;
			_right = right;
			_joinType = joinType;
			_condition = condition;
		}
		public SqlSource Left {
			get {
				return _left;
			}
		}
		public SqlSource Right {
			get {
				return _right;
			}
		}
		public JoinType JoinType {
			get {
				return _joinType;
			}
		}
		public SqlLogicalExpression Condition {
			get {
				return _condition;
			}
		}
		public override SqlNodeType NodeType {
			get {
				return SqlNodeType.Join;
			}
		}
	}
}
